package com.wwc.config.lb;

import org.springframework.cloud.client.ServiceInstance;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Random;

/**
 * 自定义随机算法
 */
@Component
public class MyLoadBalancer implements LoadBalancer{
	@Override
	public ServiceInstance instanceList(List<ServiceInstance> serviceInstanceList){
		int index = new Random().nextInt(serviceInstanceList.size());
		return serviceInstanceList.get(index);
	}
	
}
